//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package 力扣.题库.未分类;

public class demo_1456 {
    public demo_1456() {
    }

    public static void main(String[] args) {
        System.out.println(maxVowels("abciiidef", 3));
    }

    public static int maxVowels(String s, int k) {
        String a = "aeiou";
        int l = 0;
        int r = 0;
        int count = 0;
        int out = 0;

        while(r < s.length()) {
            if (r - l + 1 <= k) {
                if (a.indexOf(s.charAt(r)) != -1) {
                    ++count;
                }

                ++r;
            } else {
                if (a.indexOf(s.charAt(r)) != -1 && a.indexOf(s.charAt(l)) == -1) {
                    ++count;
                }

                if (a.indexOf(s.charAt(r)) == -1 && a.indexOf(s.charAt(l)) != -1) {
                    --count;
                }

                ++r;
                ++l;
            }

            if (count > out) {
                out = count;
            }

            if (count == k) {
                break;
            }
        }

        return out;
    }
}
